<?php
namespace app\index\controller\traits;

trait Resource
{

/**
 * 资源对照表
 */
    public function getResourceName($id)
    {

        $res = [
            '101' => '金币',
            '102' => '钻石',
            '103' => '入侵行动值',
            '104' => '领主经验'];
        if (array_key_exists($id, $res)) {
            return ($res[$id]);
        } else {
            return $id;
        }
    }
/**
 * 资源转换表
 */
    public function getResource($msg)
    {

        $temp = explode('=', $msg);
        if (2 == count($temp)) {
            return ($this->getResourceName($temp[0]) . '=' . $temp[1]);
        } else {
            return $msg;
        }
    }

}
